﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YXY.Invoice.Models
{
    public class DbContext
    {

        public SqlSugarClient Db;   //用来处理事务多表查询和复杂的操作
        public DbContext()
        {
            Db = new SqlSugarClient(new ConnectionConfig()
            {
                DbType = SqlSugar.DbType.MySql,
                ConnectionString = "server=rm-2zeijw3w0f40cgmo4uo.mysql.rds.aliyuncs.com;Database=sanyue_auth;Uid=sanyue;Pwd=Sanyue666;SslMode=none;",
                IsAutoCloseConnection = true,
            });
            //调式代码 用来打印SQL 
            Db.Aop.OnLogExecuting = (sql, pars) =>
            {
                Console.WriteLine(sql);//输出sql
                Console.WriteLine(string.Join(",", pars?.Select(it => it.ParameterName + ":" + it.Value)));//参数
            };
        }
    }
}
